package com.ruoyi.web.controller.system;

import java.util.List;
import java.util.UUID;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TbVirus;
import com.ruoyi.system.service.ITbVirusService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 病毒感染表Controller
 * 
 * @author ruoyi
 * @date 2025-02-20
 */
@RestController
@RequestMapping("/system/virus")
public class TbVirusController extends BaseController
{
    @Autowired
    private ITbVirusService tbVirusService;

    /**
     * 查询病毒感染表列表
     */
    @PreAuthorize("@ss.hasPermi('system:virus:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbVirus tbVirus)
    {
        startPage();
        List<TbVirus> list = tbVirusService.selectTbVirusList(tbVirus);
        return getDataTable(list);
    }

    /**
     * 导出病毒感染表列表
     */
    @PreAuthorize("@ss.hasPermi('system:virus:export')")
    @Log(title = "病毒感染表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbVirus tbVirus)
    {
        List<TbVirus> list = tbVirusService.selectTbVirusList(tbVirus);
        ExcelUtil<TbVirus> util = new ExcelUtil<TbVirus>(TbVirus.class);
        util.exportExcel(response, list, "病毒感染表数据");
    }

    /**
     * 获取病毒感染表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:virus:query')")
    @GetMapping(value = "/{virusId}")
    public AjaxResult getInfo(@PathVariable("virusId") String virusId)
    {
        return success(tbVirusService.selectTbVirusByVirusId(virusId));
    }

    /**
     * 新增病毒感染表
     */
    @PreAuthorize("@ss.hasPermi('system:virus:add')")
    @Log(title = "病毒感染表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbVirus tbVirus)
    {
        tbVirus.setVirusId(UUID.randomUUID().toString().replaceAll("-", ""));
        return toAjax(tbVirusService.insertTbVirus(tbVirus));
    }

    /**
     * 修改病毒感染表
     */
    @PreAuthorize("@ss.hasPermi('system:virus:edit')")
    @Log(title = "病毒感染表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbVirus tbVirus)
    {
        return toAjax(tbVirusService.updateTbVirus(tbVirus));
    }

    /**
     * 删除病毒感染表
     */
    @PreAuthorize("@ss.hasPermi('system:virus:remove')")
    @Log(title = "病毒感染表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{virusIds}")
    public AjaxResult remove(@PathVariable String[] virusIds)
    {
        return toAjax(tbVirusService.deleteTbVirusByVirusIds(virusIds));
    }
}
